Appendix H Emacs

LCLint can be used most productively with the emacs text editor. The release package includes emacs files for running LCLint and editing code with annotations.

Running LCLint

LCLint release includes emacs/lclint.elc that defines an emacs command, M-x lclint, for running LCLint. To load this file, add this line to your .emacs file:

(load-file "<directory>/lclint.elc")

The M-x lclint command is similar to M-x compile, except it jumps to the exact column location of the error message, instead of the beginning of the line. After typing M-x lclint, you will be prompted for a compile command. Enter the command identically to the command that would be used to run LCLint from the command line. If errors are found, M-x next-lclint-error jumps to the point where the next error was found. (Note, this only works if +showcolumn is set to make LCLint include column numbers in error messages.)

The command can be bound to a key to enable rapid jumping through the error messages. For example, to set the key do CTRL-backslash add this line to your .emacs file:

   (global-set-key "^\" 'next-lclint-error)

Editing Abbreviations

An additional file, emacs/lclint-abbrevs contains abbreviations for LCLint syntactic comments and annotations. If it is loaded, the comment surrounding an LCLint annotation will be added automatically. For example, typing "only" and a space, will produce "/*@only@*/ ". Abbreviations are provided for each LCLint syntactic comment. The abbreviation of /*@null@*/ is nll (not null), since it is often necessary to type NULL.

Abbreviations are loaded and used when a .c or .h file is edited by adding these lines to your .emacs file:

(quietly-read-abbrev-file "<directory>/lclint-abbrevs")

(setq c-mode-hook (function (lambda nil (abbrev-mode 1))))


Next Section Contents LCLint Home Page David Evans
Systematic Program Development
evs@larch.lcs.mit.edu